//
//  CLContainerTableViewCell.m
//  MasonryTest
//
//  Created by Charles on 2016/11/26.
//  Copyright © 2016年 Charles. All rights reserved.
//

#import "CLContainerTableViewCell.h"

@implementation CLContainerTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self makeView];
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self makeView];
}

- (void)makeView {
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    UIView * superView = self.contentView;
    [self.iconView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(superView.top).offset(10);
        make.left.equalTo(superView.left).offset(10);
        make.bottom.equalTo(superView.bottom).offset(-10);
        make.right.equalTo(self.titleLabel.left).offset(-10);
        make.width.equalTo(150);
    }];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.right).offset(10);
        make.top.equalTo(self.iconView.top);
        make.bottom.equalTo(self.iconView.bottom);
        make.right.equalTo(superView.right).offset(-10);
    }];
}

- (UIImageView *)iconView {
    if (nil == _iconView) {
        _iconView = [[UIImageView alloc]init];
        _iconView.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_iconView];
    }
    return _iconView;
}

- (UILabel *)titleLabel {
    if (nil == _titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = [UIColor blackColor];
        _titleLabel.font = [UIFont systemFontOfSize:14.0f];
        _titleLabel.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
